﻿<?xml version="1.0" encoding="utf-8"?>

<xs:schema id="FormsDefinition" xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="Forms">
		<xs:complexType>
			<xs:choice minOccurs="1" maxOccurs="unbounded">
				<xs:element name="Form" type="Form" minOccurs="1" />
				<xs:element name="Rules" type="ChooseRules" minOccurs="0" maxOccurs="1" />
			</xs:choice>
		</xs:complexType>
	</xs:element>

	<xs:complexType name="ActionRule">
		<xs:attribute name="Condition" type="xs:string" use="required" />
		<xs:attribute name="Action" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="ActionRules">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="ActionRule" type="ActionRule" />
		</xs:choice>
	</xs:complexType>

	<xs:complexType name="ChooseRule">
		<xs:attribute name="Condition" type="xs:string" use="required" />
		<xs:attribute name="FormName" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="ChooseRules">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="ChooseRule" type="ChooseRule" />
		</xs:choice>
	</xs:complexType>

	<xs:complexType name="Field">
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="optional" />
		<xs:attribute name="DisplayTemplateName" type="xs:string" use="optional" />
		<xs:attribute name="EditTemplateName" type="xs:string" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Label">
		<xs:attribute name="Name" type="xs:string" use="optional" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Control">
		<xs:attribute name="WebControl" type="xs:string" use="optional" />
		<xs:attribute name="UserControl" type="xs:string" use="optional" />
		<xs:attribute name="IsFieldCtrl" type="xs:boolean" use="optional" />
	</xs:complexType>

	<xs:complexType name="TableCell">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Label" type="Label" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Control" type="Control" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Table" type="Table" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Group" type="Group" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="optional" />
		<xs:attribute name="Title" type="xs:string" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="TableRow">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Cell" type="TableCell" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="optional" />
		<xs:attribute name="Title" type="xs:string" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Table">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Row" type="TableRow" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="optional" />
		<xs:attribute name="ShowBorders" type="xs:boolean" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Group">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Table" type="Table" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Label" type="Label" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Control" type="Control" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Tab">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Group" type="Group" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Table" type="Table" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Label" type="Label" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Control" type="Control" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Tabs">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Tab" type="Tab" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Visible" type="xs:boolean" use="optional" />
		<xs:attribute name="Width" type="xs:string" use="optional" />
		<xs:attribute name="Height" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Button">
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="UseStandardImage" type="xs:boolean" use="required" />
		<xs:attribute name="ImageUrl16" type="xs:string" use="optional" />
		<xs:attribute name="ImageUrl32" type="xs:string" use="optional" />
		<xs:attribute name="ImageX" type="xs:int" use="optional" />
		<xs:attribute name="ImageY" type="xs:int" use="optional" />
		<xs:attribute name="ImageLang" type="xs:int" use="optional" />
		<xs:attribute name="Command" type="xs:string" use="required" />
		<xs:attribute name="CommandEnable" type="xs:string" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Security" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="CreateDocumentButton">
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="UseStandardImage" type="xs:boolean" use="required" />
		<xs:attribute name="ImageUrl16" type="xs:string" use="optional" />
		<xs:attribute name="ImageUrl32" type="xs:string" use="optional" />
		<xs:attribute name="ImageX" type="xs:int" use="optional" />
		<xs:attribute name="ImageY" type="xs:int" use="optional" />
		<xs:attribute name="ImageLang" type="xs:int" use="optional" />
		<xs:attribute name="Command" type="xs:string" use="optional" />
		<xs:attribute name="CommandEnable" type="xs:string" use="optional" />
		<xs:attribute name="Enabled" type="xs:boolean" use="optional" />
		<xs:attribute name="Security" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
		<xs:attribute name="ListId" type="xs:string" use="required" />
		<xs:attribute name="ContentTypeId" type="xs:string" use="required" />
		<xs:attribute name="Source" type="xs:string" use="required" />
		<xs:attribute name="RootFolder" type="xs:string" use="required" />
	</xs:complexType>

	<xs:simpleType name="ButtonGroupTemplate">
		<xs:restriction base="xs:string">
			<xs:enumeration value="SimpleTemplate" />
			<xs:enumeration value="ThreeRowTemplate" />
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="ButtonGroup">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Button" type="Button" />
			<xs:element name="CreateDocumentButton" type="CreateDocumentButton" />
		</xs:choice>

		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="Template" type="ButtonGroupTemplate" use="optional" />
		<xs:attribute name="Security" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="ButtonTab">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="ButtonGroup" type="ButtonGroup" />
		</xs:choice>

		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="Initial" type="xs:boolean" use="optional" />
		<xs:attribute name="Security" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="ButtonTabs">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="ButtonTab" type="ButtonTab" />
		</xs:choice>
	</xs:complexType>

	<xs:complexType name="MenuItem">
		<xs:sequence>
			<xs:element name="Query" type="xs:string" minOccurs="1" maxOccurs="1" />
			<xs:element name="ControlSrc" type="xs:string" minOccurs="1" maxOccurs="1" />
			<xs:element name="MenuItems" type="MenuItem" minOccurs="1" maxOccurs="unbounded" />
		</xs:sequence>
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
		<xs:attribute name="IsSelected" type="xs:boolean" use="required" />
	</xs:complexType>

	<xs:simpleType name="ScriptDisplacement">
		<xs:restriction base="xs:string">
			<xs:enumeration value="Head" />
			<xs:enumeration value="Body" />
		</xs:restriction>
	</xs:simpleType>

	<xs:complexType name="Script">
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Src" type="xs:string" use="optional" />
		<xs:attribute name="Text" type="xs:string" use="optional" />
		<xs:attribute name="Displacement" type="ScriptDisplacement" use="optional" />
		<xs:attribute name="Security" type="xs:string" use="optional" />
		<xs:attribute name="Condition" type="xs:string" use="optional" />
	</xs:complexType>

	<xs:complexType name="Scripts">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Script" type="Script" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="required" />
	</xs:complexType>

	<xs:complexType name="Form">
		<xs:choice minOccurs="1" maxOccurs="unbounded">
			<xs:element name="Tabs" type="Tabs" minOccurs="0" maxOccurs="1" />
			<xs:element name="Rules" type="ActionRules" minOccurs="0" maxOccurs="1" />
			<xs:element name="ButtonTabs" type="ButtonTabs" minOccurs="0" maxOccurs="1" />
			<xs:element name="Scripts" type="Scripts" minOccurs="0" maxOccurs="1" />
			<xs:element name="Table" type="Table" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Group" type="Group" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Field" type="Field" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="Control" type="Control" minOccurs="0" maxOccurs="unbounded" />
			<xs:element name="MenuItem" type="MenuItem" minOccurs="0" maxOccurs="unbounded" />
		</xs:choice>
		<xs:attribute name="Name" type="xs:string" use="required" />
		<xs:attribute name="Title" type="xs:string" use="required" />
	</xs:complexType>
</xs:schema>